package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;

@Mapper
public interface SetmealDishMapper {
    /**
     * 通过dishId查询MealId,这是查询个数
     * @param ids
     * @return
     */
    List<Long> getSetMealIdByDishId(List<Long> ids);

    /**
     * 保存套餐与dish的关系
     * @param list
     */
    void save(List<SetmealDish> list);

    /**
     * 通过dish的id在setmeal中进行查找
     * @param id
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id=#{id}")
    List<SetmealDish> getSetMealIdByDishIdForSetmealDish(Long id);

    /**
     * 删除关系表中的数据
     * @param id
     */
    @Delete("delete from setmeal_dish where setmeal_id=#{id}")
    void delete(Long id);
}
